﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TournamentDatabase.Database;

namespace TournamentDatabase.Objects
{
	public class Competitor : Member
	{
		private Gender m_gender;
		private DateTime m_birthDate;
		private string m_repGroup;
		private string m_rankTitle;
		private string m_arenaName;

		public Gender Gender
		{
			get { return m_gender; }
			set { m_gender = value; }
		}
		public DateTime BirthDate
		{
			get { return m_birthDate; }
			set { m_birthDate = value; }
		}
		public string RepGroup
		{
			get { return m_repGroup; }
			set { m_repGroup = value; }
		}
		public string RankTitle
		{
			get { return m_rankTitle; }
			set { m_rankTitle = value; }
		}
		public string ArenaName
		{
			get { return m_arenaName; }
			set { m_arenaName = value; }
		}

		public Competitor() : this(0, Gender.Male, DateTime.Today, "", "", "") { }
		public Competitor(int mid, Gender gender, DateTime birthDate, string repGroup, string rankTitle, string arenaName)
		{
			m_mid = mid;
			m_gender = gender;
			m_birthDate = birthDate;
			m_repGroup = repGroup;
			m_rankTitle = rankTitle;
			m_arenaName = arenaName;
		}
		public Competitor(OracleDataReader odr) : base(odr)
		{
			Gender = (Gender)Enum.Parse(typeof(Gender), odr["gender"].ToString(), true);
			//MemberID = int.Parse(odr["mid"]);
			BirthDate = DateTime.Parse(odr["birthDate"]);
			RepGroup = odr["repGroup"].ToString();
			RankTitle = odr["rankTitle"].ToString();
			ArenaName = odr["arenaName"].ToString();
		}

        public static List<Competitor> ParseCompetitor(OracleDataReader odr)
        {
            List<Competitor> list = new List<Competitor>();
            while (odr.Read())
            {
                list.Add(new Competitor());
            }
            return list;
        } 
	}

}
